﻿#include <iostream>
#include <entt/entt.hpp>

struct Position {
  float x, y;
};

struct Velocity {
  float dx, dy;
};

int main() {
  entt::registry registry;

  // 创建一个实体并赋予它Position和Velocity组件
  auto entity = registry.create();
  registry.emplace<Position>(entity, 10.0f, 20.0f);
  registry.emplace<Velocity>(entity, 1.0f, 1.5f);

  // 获取并使用组件
  auto& pos = registry.get<Position>(entity);
  auto& vel = registry.get<Velocity>(entity);

  std::cout << "Initial Position: (" << pos.x << ", " << pos.y << ")\n";
  std::cout << "Velocity: (" << vel.dx << ", " << vel.dy << ")\n";

  // 更新位置
  pos.x += vel.dx;
  pos.y += vel.dy;

  std::cout << "Updated Position: (" << pos.x << ", " << pos.y << ")\n";

  return 0;
}
